<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/validation.jsp" %>
<%@ include file="/commons/dateTime.jsp" %>
<html>
<head>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript"
	src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript">
var index = null;
   function openPerItemOfDispAdd(){
   		var url = "${ctx}/occupation_perfectItemDispatchAction.do?method=initPerItemReqsAdd&perfectItemDispatchId=${perfectItemDispatchId}";
		top.windowOpen(url, 'PerItemReqsOfDispAdd', '派工列表', 420, 600, true, "PerItemReqsOfDispAdd");
   }
   function showPerItemOfDispDelete(){
   		if( index == null ){
			ErrorAlert('请选择一条数据才能删除！');
		}else{
			var checkUrl = '${ctx}/occupation_perfectItemDispatchAction.do?method=checkDeletePerfectItemIsTrue&keyword=' + index;
			new Ajax.Request(
	                   checkUrl,
	                   {method: 'post' , onComplete: function(response){
	                	   ajaxSubmitException(response.responseText);
	                	   AlarmConfirm('您确定删除此记录吗？',"EditPage","deleteRecord");
	                   }});
			
		}
   }
	function deleteRecord(){
		var url="${ctx}/occupation_perfectItemDispatchAction.do?method=deltePerfectItemRequistion";
		var parameter = "index="+index;
		var myAjax = new Ajax.Request(
	                   url,
	                   {method: 'post', parameters:parameter , onComplete: showResponseDelete}
	                   );
	}
	function showResponseDelete(transport){
		ajaxSubmitException(transport.responseText);
		if(transport.responseText=="false"){
			FailureAlert('删除失败！');
		}else{
			reloadPerfectItemOfDispaList();
		}
	}

	function setIndex(id){
	index=id;
	}

	function reloadPerfectItemOfDispaList(){
	index=null;
		$('perfectItemOfDispaList').src="${ctx}/occupation_perfectItemDispatchAction.do?method=initPerfectItemListCache";
	}

	function sumbmitForm(){
		$('contractorInfoConfigName').value = $('contractorInfoConfigId').options[$('contractorInfoConfigId').selectedIndex].text;

	 var isTrue=$("editForm").fireEvent("onSubmit");
      if(isTrue)
      {
      var urll='';
         if(document.getElementById("keyword").value==''){
         urll = "${ctx}/occupation_perfectItemDispatchAction.do?method=addPerfectItemDispatch";
         }else{
         urll = "${ctx}/occupation_perfectItemDispatchAction.do?method=editPerfectItemDispatch";
         }

       var param=document.editForm.serialize();

	 new Ajax.Request(urll,{method: 'post',parameters: param,onSuccess : function(result){
	 var resultText = result.responseText.strip();
		ajaxSubmitException(resultText);
		var iframe=findFrame("main");
			iframe.refresh();
        windowClose();
      }});
	}
   }

</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>整改派工-新增/编辑</title>
</head>
<body>
<form id="editForm" name="editForm" method="post" action="${ctx}/occupation_perfectItemDispatchAction.do?method=editPerfectItemDispatch" class="required-validate">
<input type="hidden" name="contractorInfoConfigName" id="contractorInfoConfigName" value="" />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle" /> <span class="window_head_intext">派 工</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" ""border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top" class="aux_outtable_color">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">


<input type="hidden" name="keyword" value="${keyword}">
			<tr>
            <td valign="top" class="aux_intable_td1">派工单号：</td>
            <td class="aux_intable_td2">
            <input type="hidden" name="dispatchNumber" value="${perfectItemDispatchVO.dispatchNumber }">
            ${perfectItemDispatchVO.dispatchNumber }
            </td>
            </tr>
          <tr>
            <td class="aux_intable_td1">承包商：</td>
            <td class="aux_intable_require">
           	<pms:unitedSelect
                       		name="contractorInfoConfigId"
                       		id="contractorInfoConfigId"
                       		optionLabel="contractorInfoName"
                       		optionValue="keyword"
                       		selectText="请选择..."
                       		value="${perfectItemDispatchVO.contractorInfoConfigId }"
                       		dataList="${contractorInfoConfigList }"
                       		className="select-one-required">
                    	</pms:unitedSelect>
              </td>
            </tr>
          <tr>
            <td class="aux_intable_td1">派工日期：</td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><input name="dispatchDate" id="dispatchDate" type="text" class="required validate-date-yyyy-mm-dd" value="${perfectItemDispatchVO.dispatchDate }" size="16" afterInsert="tempButon"/></td>
                <td width="4">&nbsp;</td>
                <td><a href="#"><img id="dispatchDateImageBtn" src="${ctx}/images/ico_clock.gif" alt="请点选查找日期" border="0" /></a><span id="tempButon"><span></td>
              </tr>
            </table></td>
            </tr>
		  <tr>
            <td valign="top" class="aux_intable_td1">备 注：</td>
            <td class="aux_intable_td2"><textarea name="description" id="description" cols="32" rows="2" class="textareatext max-length-200">${perfectItemDispatchVO.description }</textarea></td>
            </tr>
</form>
		  <tr>
	  	<td colspan="4" class="aux_intable_td1">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
                        <tr>
                          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" >
                              <tr>

      <td class="bg_toolBar2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="65%">&nbsp;</td>
          <td width="35%" align="right">
<!--------------------------右边图标01----------------------------------->
		  <table border="0" cellpadding="0" cellspacing="0" id="ico1">
             <tr>
			 <td class="toolbarico"><a href="#"  onclick="openPerItemOfDispAdd();"onfocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="添 加"/>&nbsp;</a></td>

                <td class="toolbarico"><a href="#" onClick="showPerItemOfDispDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom" /></a></td>

                <td class="toolbarico">&nbsp;</td>

              </tr>
           </table>
          <!--------------------------右边图标02----------------------------------->
          </td>
        </tr>
      </table></td>
    </tr>
                              <tr>
                                <td colspan="5" >
								<div class="tab_bgline">
	<div id="affair" class="tab_line"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td valign="top">
							<iframe src="${ctx }/occupation_perfectItemDispatchAction.do?method=initPerfectItemListCache" name="perfectItemOfDispaList" id="perfectItemOfDispaList" width="100%" height="200px" frameborder="0" > </iframe>
                                      </tr>
                                  </table>
								  </div>
								  </div>



								  </td>
                              </tr>
                          </table></td>
                        </tr>
            </table>		</td>
	  </tr>

        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="sumbmitForm();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick=" windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onblur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 取 消</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>


</body>
<script type="text/javascript">
  Calendar.setup(
              {
	              inputField : "dispatchDate", // ID of the input field
	              ifFormat : "%Y-%m-%d", // the date format
	              button : "dispatchDateImageBtn", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true

              }
       );

</script>
</html>